import matplotlib.pyplot as plt
import os
import numpy as np
os.environ['CUDA_VISIBLE_DEVICES'] = '3'

# R = [0.005, 0.01, 0.015, 0.02, 0.03, 0.05, 0.07, 0.10, 0.12]
# Acc = [93.40, 93.70, 93.58, 93.57, 93.73, 93.56, 93.79, 93.90, 93.32]
# poisonedACC = [98.19, 99.70, 99.65, 99.58, 99.48, 99.88, 99.94, 100.00, 100.00]

R = [0.01, 0.02, 0.03, 0.05, 0.07, 0.10, 0.12]
Acc = [93.70, 93.57, 93.73, 93.56, 93.79, 93.90, 93.32]
poisonedACC = [99.70, 99.58, 99.48, 99.88, 99.94, 100.00, 100.00]

# R_corner = [0.01, 0.02, 0.03, 0.04, 0.30, 0.50, 0.70, 0.90]
# Acc_corner = [93.67, 93.40, 93.96, 93.50, 93.23, 92.17, 90.73, 90.98]
# poisonedACC_corner = [10.04, 10.20, 10.37, 10.38, 70.28, 69.78, 71.27, 84.19]

R_corner = [0.01, 0.10, 0.30, 0.50, 0.70, 0.90, 1]
Acc_corner = [93.67, 93.25, 93.23, 92.17, 90.73, 90.98, 88.76]
poisonedACC_corner = [10.04, 57.41, 70.28, 69.78, 71.27, 84.19, 83.47]

fig, ax = plt.subplots()
x = np.array(R)
ax.plot(x, np.array(Acc), marker='o', label='CDA')
ax.plot(x, np.array(poisonedACC), marker='^', label='ASR')
ax.set_xlabel('R')
ax.set_ylabel('Acc')
ax.set_title("CDA and ASR based on R")
ax.legend()
ax.grid(linestyle='--')
plt.show()
